//
//  DiscoverTableViewCell.m
//  group14
//
//  Created by lanou3g on 15/11/11.
//  Copyright © 2015年 吕志伟. All rights reserved.
//

#import "DiscoverTableViewCell.h"

#import "FriendsSecondTableViewController.h"

@implementation DiscoverTableViewCell

// 初始化方法
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.myImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.myImageView];
        
        self.nameButton = [[UIButton alloc] init];
        [self.contentView addSubview:self.nameButton];
        
        self.contentLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.contentLabel];
        
        self.commentButton = [[UIButton alloc] init];
        [self.contentView addSubview:self.commentButton];
        
        self.supportButton = [[UIButton alloc] init];
        [self.contentView addSubview:self.supportButton];
        
        
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.myImageView.frame = CGRectMake(10, 10, 50, 50);
    
    // UIButton属性titleLabel（UILabel），Button可以自适应宽度
    self.nameButton.titleLabel.frame = CGRectMake(CGRectGetMaxX(self.myImageView.frame) + 10, CGRectGetMinX(self.myImageView.frame), self.frame.size.width - self.myImageView.frame.size.width - 30, 20);
    
    self.nameButton.frame = self.nameButton.titleLabel.frame;
    
    [self.nameButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    
    self.nameButton.titleLabel.numberOfLines = 0;
    [self.nameButton sizeToFit];
    
    self.contentLabel.frame = CGRectMake(CGRectGetMaxX(self.myImageView.frame) + 10, CGRectGetMinY(self.myImageView.frame) + 40, self.frame.size.width - self.myImageView.frame.size.width - 30, 20);
    
    // 自适应高度
    self.contentLabel.numberOfLines = 0;
    [self.contentLabel sizeToFit];
    
    // 点赞按钮
    self.supportButton.frame = CGRectMake((self.frame.size.width / 4) * 3, CGRectGetMaxY(self.contentLabel.frame) + 10, 20, 20);
    
    [self.supportButton setImage:[UIImage imageNamed:@"iconfont-dianzan-2"] forState:UIControlStateNormal];
    
    
    // 评论按钮
    self.commentButton.frame = CGRectMake(self.frame.size.width / 4 * 3 + 40, CGRectGetMaxY(self.contentLabel.frame) + 10, 20, 20);
    
    [self.commentButton setImage:[UIImage imageNamed:@"iconfont-pinglun-2"] forState:UIControlStateNormal];
    
    
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
